package cn.tedu.oa.department.controller;

import cn.tedu.oa.base.response.JsonResult;
import cn.tedu.oa.basicInfo.pojo.vo.BasicInfoVO;
import cn.tedu.oa.department.pojo.dto.DepartmentQuery;
import cn.tedu.oa.department.pojo.dto.DepartmentSaveParam;
import cn.tedu.oa.department.service.DepartmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/oa1/department")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    @PostMapping("/delete/{id}")
    public JsonResult  delete(@PathVariable Integer id){
        log.info("删除部门信息，id:{}",id);
        departmentService.delete(id);
        return JsonResult.ok();
    }
    @PostMapping("/save")
    public JsonResult save(DepartmentSaveParam departmentSaveParam){
        log.info("保存部门信息，参数:{}",departmentSaveParam);
        departmentService.save(departmentSaveParam);
        return JsonResult.ok();
    }
    @GetMapping("/select")
    public JsonResult  select(DepartmentQuery departmentQuery){
        log.info("查询部门信息，参数:{}",departmentQuery);
        List<BasicInfoVO> list = departmentService.select(departmentQuery);
        return JsonResult.ok(list);
    }
    @GetMapping("/selectParent")
    public JsonResult  selectParent(DepartmentQuery departmentQuery){
        log.info("查询部门信息，参数:{}",departmentQuery);
        List<BasicInfoVO> list = departmentService.selectParent(departmentQuery);
        return JsonResult.ok(list);
    }


}
